import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {defHttp} from "@/utils/http/axios";
import {list as listSpecification} from "/@/views/shop/specification/ShSpecification.api";
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '商品名称',
    align:"center",
    dataIndex: 'commodityName'
   },
   {
    title: '商品规格',
    align:"center",
    dataIndex: 'specificationItemNames'
   },
   {
    title: '价格(元)',
    align:"center",
    dataIndex: 'price'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '商品名',
    field: 'commodityName',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '商品名',
    field: 'commodityId',
    component: 'JSearchSelect',
    componentProps:(formModel)=>{
      return {
        dict:"sh_commodity,name,id",
        pageSize:3,
        async:true,
      }
    },
    dynamicDisabled:(values)=>{
      if(values.id){
        return true;
      }else {
        return false;
      }
    }

  },
  {
    label: '价格(元)',
    field: 'price',
    component: 'InputNumber',
    required:true,
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  commodityId: {title: '商品id',order: 0,view: 'text', type: 'string',},
  specificationItemIds: {title: '商品规格',order: 1,view: 'text', type: 'string',},
  price: {title: '价格',order: 2,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
